package samples.d2.parallels.trames 
{
	import samples.BaseSample;
	import shapes.shapes2D.Dot;
	import shapes.shapes2D.Line;
	/**
	 * @author Nicolas Barradeau
	 * http://en.nicoptere.net
	 */
	public class Trame0 extends BaseSample
	{
		
		private var d0:Dot;
		private var d1:Dot;
		private var line:Line;
		private var lines:Vector.<Line>;
		
		public function Trame0() 
		{
			
			reset();
		}
		
		private function reset( horizontal:int = 10, vertical:int = 10 ):void
		{
			lines = new Vector.<Line>();
			
			var width:int = 500;
			var height:int = 500;
			
			var offsetX:int = 0;
			var offsetY:int = 0;
			
			var i:int;
			for ( i = 0; i <= horizontal; i++ )
			{
				
				offsetX = -width / 2 + ( width / horizontal ) * i;
				
				d0 = new Dot( sw/2 + offsetX, sh / 2 - height / 2 );
				d1 = new Dot( sw/2 + offsetX, sh / 2 + height / 2 );
				line = new Line( d0, d1 );
				
				lines.push( line );
				
			}
			
			for ( i = 0; i <= vertical; i++ )
			{
				
				offsetY = -height / 2 + ( height / vertical ) * i;
				
				d0 = new Dot( sw/2 - width / 2, sh / 2 + offsetY );
				d1 = new Dot( sw/2 + width / 2, sh / 2 + offsetY );
				line = new Line( d0, d1 );
				
				lines.push( line );
				
			}
			render();
		}
		
		private function render():void
		{
			graphics.clear();
			for each( line in lines )
			{
				graphics.lineStyle( 0, color );
				line.d0.draw( graphics );
				line.d1.draw( graphics );
				graphics.lineStyle( line.strokeWidth, color, line.strokeAlpha );
				line.draw( graphics );
			}	
		}
	}

}